<template>
  <div id="external-div">
    <div class="header">
      <div class="header-content">
        <div class="logo">
          <img class="img" src="../../vue-cheese-world/src/assets/logo.png" alt="logo"/>
          <span>Vue-Cheese-World</span>
        </div>
        <div class="div-nav">
          <nav>
            <router-link to="/">首页</router-link>
            |
            <router-link to="/about">关于</router-link>
            |
            <router-link to="/login">登录</router-link>
          </nav>
        </div>

        <div class="personal-center">
          <div class="personal-center-content" @click="toLogin()">
            <el-dropdown>
              <el-avatar
                  :src="profilePicture"
              />
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item v-if="loginState === '未登录'" @click="toLogin()">登录</el-dropdown-item>
                  <el-dropdown-item v-if="loginState === '未登录'" @click="toRegistered()">注册</el-dropdown-item>
                  <el-dropdown-item v-if="loginState === '登录'">个人中心</el-dropdown-item>
                  <el-dropdown-item v-if="loginState === '登录'">账户管理</el-dropdown-item>
                  <el-dropdown-item v-if="loginState === '登录'">注销登录</el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
          </div>
        </div>
      </div>
    </div>
    <div class="main">
      <div class="content">
        <router-view/>
      </div>
      <div class="footer">Footer</div>
    </div>
  </div>

</template>

<script>
export default {
  name: 'App',

  data() {
    return {
      profilePicture: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
      loginState: '未登录'
    }
  },
  methods: {
    toLogin() {
      this.$router.push('/login')
    },

    toRegistered() {
      const { href } = this.$router.resolve({ path: '/registered' });
      window.open(href, '_blank');
    }
  }
}
</script>

<style scoped>
@import '../../vue-cheese-world/src/style/app.css';


</style>
